package fhp.hlhj.giantfold.adapter

import android.content.Context
import android.support.v4.view.PagerAdapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import fhp.hlhj.giantfold.R

/**
 * Created by Administrator on 2018\2\11 0011.
 */
class NotePagerAdp(private val context: Context,private val listner:IBt):PagerAdapter() {

    override fun isViewFromObject(p0: View?, p1: Any?): Boolean {
        return p0==p1
    }

    override fun instantiateItem(container: ViewGroup?, position: Int): Any {
        val view = LayoutInflater.from(context).inflate(R.layout.note_pager, null)
        val img = view.findViewById<ImageView>(R.id.img)
        val btexit = view.findViewById<ImageView>(R.id.btExit)
        img.setImageResource(when(position){
            0->{
                R.mipmap.bendish_zzs
            }
            1->{
                R.mipmap.bendish_zz
            }
            else->{
                0
            }
        })
        btexit.setOnClickListener {
            listner.finishIt()
        }

        container?.addView(view)
        return view

    }
    override fun getCount(): Int {
        return 2
    }
    interface IBt{
        fun finishIt()
    }
}